import instance from 'utils/request'
// 获取频道列表
export const getChannelAPI = () => {
  return instance({
    url: '/v1_0/channels'
  })
}
// 获取文章列表
export const getArticlesAPI = (params) => {
  return instance({
    url: '/v1_0/mp/articles',
    params
  })
}
// 删除文章
export const deleteArticlesByIdAPI = (id) => {
  return instance({
    url: `/v1_0/mp/articles/${id}`,
    method: 'DELETE'
  })
}

// 发布文章
export const publishArticlesAPI = ({ draft = false, ...data }) => {
  return instance({
    url: `/v1_0/mp/articles?draft=${draft}`,
    method: 'post',
    data
  })
}
// 根据id获取文章详情
export const getArticlesByIdAPI = (id) => {
  return instance({
    url: `/v1_0/mp/articles/${id}`
  })
}
// 根据id编辑文章
export const editArticleByIdAPI = ({ id, draft = false, ...data }) => {
  return instance({
    url: `/v1_0/mp/articles/${id}?draft=${draft}`,
    method: 'PUT',
    data
  })
}